package com.stu_ques.users.pojo;

import java.io.Serializable;
import java.util.Date;

import com.stu_ques.common.util.DateUtil;

/**
 * 	创建一个学生表Pojo
 * 	学生表的属性	id,等级,名字,性别,生日,老家,毕业学校,分数,提问的总次数,正确次数,错误次数;
 * 				正确率;(今日总次数,今日正确次数,今日正确率)创建时间,结束时间 
 * */
public class Student implements Serializable
{
	/*	学生的学号	*/
	private int id;
	/*	等级	*/
	private int levelId;
	/*	学生的姓名	*/
	private String name;
	/*	学生的性别 true男 , false女	*/
	private boolean sex;
	/*	学生的生日	*/
	private String age;
	/*	老家的地址	*/
	private String address;
	/*	毕业学校	*/
	private String school;
	/*	每局分数	*/
	private int oneGame = 2;
	/*	分数	*/
	private int fraction;
	/*	提问的总次数	*/
	private int total;
	/*	正确次数	*/
	private int correct;
	/*	错误次数 	*/
	private int error;
	/*	正确率	*/
	private double correctRate;
	/*	今日总次数	*/
	private int todayTotal;
	/*	今日正确的次数	*/
	private int todayCorrect;
	/*	今日错误的次数	*/
	private int todayRrror;
	/*	今日正确率	*/
	private double todayCorrectRate;
	/*	创建时间	*/
	private Date creationTime;
	/*	更新时间	*/
	private Date updateTime;
	
	/*	关联关系	*/
	private Level level;
	
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	
	public boolean isSex()
	{
		return sex;
	}
	public void setSex(boolean sex)
	{
		this.sex = sex;
	}
	
	public String getAge()
	{
		return age;
	}
	public void setAge(String age)
	{
		this.age = age;
	}
	
	public String getAddress()
	{
		return address;
	}
	public void setAddress(String address)
	{
		this.address = address;
	}
	
	public int getFraction()
	{
		fraction = this.correct*this.oneGame;
		
		return fraction;
	}
	public int getTotal()
	{
		return total;
	}
	public void setTotal(int total)
	{
		this.total = total;
	}
	public int getCorrect()
	{
		return correct;
	}
	public void setCorrect(int correct)
	{
		this.correct = correct;
	}
	/*	错误分数等于 总分数减去正确分数	*/
	public int getError()
	{
		this.error = this.total-this.correct;
		return error;
	}
	/*	正确率等于 正确次数除以总次数	*/
	public double getCorrectRate()
	{
		if(correct != 0)
		{
			this.correctRate = this.correct/this.total;
		}
		return correctRate;
	}
	public Date getCreationTime()
	{
		return creationTime;
	}
	public void setCreationTime(Date creationTime)
	{
		this.creationTime = creationTime;
	}
	public Date getUpdateTime()
	{
		return updateTime;
	}
	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}
	public String getSchool()
	{
		return school;
	}
	public void setSchool(String school)
	{
		this.school = school;
	}
	public int getTodayCorrect()
	{
		return todayCorrect;
	}
	public void setTodayCorrect(int todayCorrect)
	{
		this.todayCorrect = todayCorrect;
	}
	public int getTodayTotal()
	{
		return todayTotal;
	}
	public void setTodayTotal(int todayTotal)
	{
		this.todayTotal = todayTotal;
	}
	/*	今日答的总次数减去今日答对的次数 	*/
	public int getTodayRrror()
	{
		todayRrror = todayCorrect-todayTotal;
		
		return todayRrror;
	}
	/*	今日答对的次数除以今日答的总次数	*/
	public double getTodayCorrectRate()
	{
		todayCorrectRate = todayTotal/todayCorrect;
		return todayCorrectRate;
	}
	public int getLevelId()
	{
		return levelId;
	}
	public void setLevelId(int levelId)
	{
		this.levelId = levelId;
	}
	public Level getLevel()
	{
		return level;
	}
	public void setLevel(Level level)
	{
		this.level = level;
	}
	public String toString()
	{
		/*	打印男女	*/
		String sex = "";
		if(this.isSex()) 
		{
			sex= "男";
		}else 
		{
			sex="女";
		}
		/*关联关系赋值*/
		String levelName = "无";
		if(level != null)
		{
			if(this.fraction >= level.getStartScore() && this.fraction < level.getEndScore() )
			{
				levelName = this.getName();
			}
		}
		DateUtil dateUtil = new DateUtil();
		
		String ste = this.getId()+"\t"+levelName+"\t"+
					this.getName()+"\t"+sex+"\t"+this.getAge()+"\t"+
					this.getAddress()+"\t"+this.getSchool()+"\t"+this.getFraction()+"\t"+this.getTotal()+"\t"+
					this.getCorrect()+"\t"+this.getError()+"\t"+this.getCorrectRate()+"\t"+
					dateUtil.dateTimeString(this.getUpdateTime())+"\t"+
					dateUtil.dateTimeString(this.getCreationTime());
		return ste;
	}
}